Imports System
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Public Class MyWebForm
    Inherits System.Web.UI.Page
    Protected WithEvents Select1 As System.Web.UI.HtmlControls.HtmlSelect
    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    Protected WithEvents lstUsers As System.Web.UI.WebControls.DropDownList

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            Dim myConn As SqlConnection
            Dim myCom As SqlCommand
            Dim myDrd As SqlDataReader
            Dim strSQL = "select * from tblUsers "
            strSQL += "order by UserName ASC"
            myConn = New SqlConnection(ConfigurationSettings.AppSettings("cons"))
            myConn.Open()
            myCom = New SqlCommand(strSQL, myConn)
            myDrd = myCom.ExecuteReader()
            lstUsers.DataSource = myDrd
            lstUsers.DataBind()
            myConn.Close()
        End If

    End Sub

    Private Sub lstUsers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstUsers.SelectedIndexChanged

    End Sub

    Private Sub Select1_ServerChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Select1.ServerChange
        Dim i = 0
        For i = 0 To Select1.Items.Count
            MsgBox(Select1.Items(i).Selected)
        Next
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        DataGrid1.PagerStyle.PageButtonCount = 10
        DataGrid1.PagerStyle.Mode = PagerMode.NumericPages
        DataGrid1.PagerStyle.PrevPageText = "as"
        DataGrid1.AllowCustomPaging = True
        DataGrid1.AllowSorting = True
    End Sub
    Function sendMail(ByVal Fr As String, ByVal Re As String, ByVal Cc As String, ByVal Bcc As String, ByVal Subject As String, ByVal Body As String) As Boolean
        Dim MailMessageObject As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage()
        MailMessageObject.To = Re
        MailMessageObject.From = Fr
        MailMessageObject.Cc = Cc
        MailMessageObject.Bcc = Bcc
        MailMessageObject.Subject = Subject
        MailMessageObject.Body = Body
        MailMessageObject.BodyFormat = System.Web.Mail.MailFormat.Text
        MailMessageObject.BodyFormat = System.Web.Mail.MailFormat.Html
        System.Web.Mail.SmtpMail.SmtpServer = "localhost"
        System.Web.Mail.SmtpMail.Send(MailMessageObject)
        Return True
    End Function
End Class
